package com.example.controller;

import com.example.service.RecomService;
import com.example.service.RecommendationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

//@RestController
//@RequestMapping("/api/recommendations")
//public class RecomController {
//    @Autowired
//    private RecommendationService recommendationService;
//
//    public RecomController(RecommendationService recommendationService) {
//        this.recommendationService = recommendationService;
//    }
//
//    @GetMapping
//    public ResponseEntity<List<String>> getRecommendations(@RequestParam Long userId) {
//        List<String> recommendations = recomService.getRecommendations(userId);
//        return ResponseEntity.ok(recommendations);
//    }
//}

@RestController
public class RecomController {
    private final RecommendationService recommendationService;

    @Autowired
    public RecomController(RecommendationService recommendationService) {
        this.recommendationService = recommendationService;
    }

    // 修改接口，接受用户ID而非搜索词
    @GetMapping("/recommendations")
    public ResponseEntity<List<String>> getRecommendations(@RequestParam Long userId) {
        List<String> recommendations = recommendationService.recommendBasedOnUserHistory(userId);
        return ResponseEntity.ok(recommendations);
    }
}

